package com.bss.dao;

import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.andy.basics.Dao;
import com.bss.model.Payment;
import com.bss.model.PaymentType;

@Repository
public class PaymentDao extends Dao<Payment> {

	public List<Payment> findPayments(final PaymentType paymentType, final Date to) {
		return this.findWithParameters("date <= ? and paymentType = ? order by date asc", to, paymentType);
	}

	public List<Payment> findPayments(final PaymentType paymentType, final Date from, final Date to) {
		if (from == null) {
			return this.findPayments(paymentType, to);
		}
		return this.findWithParameters("date >= ? and date <= ? and paymentType = ? order by date asc", from, to, paymentType);
	}

	public List<Payment> findPayments(final Date from, final Date to) {
		return this.findWithParameters("date >= ? and date <= ? order by date asc", from, to);
	}

	public List<Payment> findPayments(final Date to) {
		return this.findWithParameters("date <= ? order by date asc", to);
	}

}
